import { createStore } from "vuex";
import { getLyric } from "@/api/home";
export default createStore({
  state: {
    playlist: [
      {
        al: {
          id: 126813419,
          name: "这场青春值得骄傲",
          pic: 109951165942037070,
          picUrl:
            "https://p1.music.126.net/QLEk_iY2Us_dSWyUdgn-6A==/109951165942037070.jpg",
          pic_str: "109951165942037070",
        },
        id: 1841819403,
        ar: [
          {
            name: "紫色",
          },
        ],
      },
    ],
    playListIndex: 0,
    isShow: true,
    detailShow: false,
    lyricList: {},
  },
  getters: {},
  mutations: {
    CHANHRISSHOE(state, value) {
      state.isShow = value;
    },
    UPDATEMUSIC(state, value) {
      state.playlist = value;
    },
    UPDATEPLAYINDEX(state, value) {
      state.playListIndex = value;
    },
    UODATEDETAIL(state) {
      state.detailShow = !state.detailShow;
    },
    UPDATELYRIC(state, value) {
      state.lyricList = value;
    },
  },
  actions: {
    async getMusicLyric(context, value) {
      let res = await getLyric(value);
      context.commit("UPDATELYRIC", res.data.lrc);
    },
  },
  modules: {},
});
